home *** CD-ROM | disk | FTP | other *** search
/ Sun Solutions 2000 #2 / Sun Solutions CD (Volume 2 2000)(Special Focus - Java Technologies)(Disc 1).ISO / products / Software / AppliedReasoning / _install / launchit.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2000-03-08  |  6KB  |  268 lines

  1. #!/bin/sh 
  2. if [ "$HOME" = "" ]; then
  3.         HOME="/"; export HOME
  4. fi
  5. #
  6. # Generic launch script for use with MDSS cdrom mechanism 
  7. #
  8. # marc.sacoolas@sun.com 
  9. #
  10. #**********************
  11. #     Begin subs
  12. #**********************
  13.  
  14. # Check if user wants to be root 
  15. check_root_maybe() {
  16. if [ "$USER" != "root" ]; then
  17.   while true
  18.   do
  19.     echo ""
  20.     echo "You may need to be root user to install this software in certain directories. \c"
  21.     echo ""
  22.     echo "Would you like to become root user? <[y/n] n> \c"
  23.     read ans
  24.      if [ "$ans" = "" ]; then 
  25.     ans="n" 
  26.      fi
  27.  
  28.      case "$ans" in
  29.       y|Y|yes|YES) echo "";echo "Enter super user \c";su root -c 'USER=root;export USER;$COMPANY_DIR/_install/launchit.sh $theARGS';exit 0
  30.             ;;
  31.       N|Q|n|q|No|quit|NO|QUIT|Quit) break 
  32.             ;;
  33.      esac
  34.   done
  35. fi 
  36. }
  37. # Check if root - manditory
  38. check_root() {
  39. if [ "$USER" != "root" ]; then
  40.   while true
  41.   do
  42.     echo ""
  43.     echo "You need to be super user to install this software. \c"
  44.     echo ""
  45.     echo "Would you like to continue with the installation? <[y/n] y> \c"
  46.     read ans
  47.      if [ "$ans" = "" ]; then 
  48.     ans="y" 
  49.      fi
  50.  
  51.      case "$ans" in
  52.       y|Y|yes|YES) echo "";echo "Enter super user \c";su root -c 'USER=root;export USER;$COMPANY_DIR/_install/launchit.sh $theARGS';exit 0
  53.             ;;
  54.       N|Q|n|q|No|quit|NO|QUIT|Quit) end_it
  55.             ;;
  56.      esac
  57.   done
  58. fi 
  59. }
  60. # terminate installation
  61. end_it () {
  62.   echo " " 
  63.   echo $1
  64.   echo " " 
  65.   echo "Hit return to end ..."
  66.   echo " "
  67.   read answer
  68.   exit 0 
  69. }
  70. # prompt to remove stuff before terminating 
  71. end_it_rm () {
  72. cd $HOME
  73. echo ""
  74. echo "Remove demo directory $installdir?"
  75.         echo "\n<[y/n] y>\c";read x
  76.         if [ "$x" = "" ];then x="y"
  77.         fi
  78.         if [ $x = "n" -o $x = "no" -o $x = "No" -o $x = "N" ];then
  79.         exit 0
  80.     fi
  81.         if [ $x = "y" -o $x = "yes" -o $x = "Yes" -o $x = "Y" ];then
  82.           rm -rf $installdir
  83.       echo " "
  84.         echo "Hit return to end ..."
  85.         echo " "
  86.           read answer
  87.           exit 0
  88.           if [ -d $path ]; then
  89.                 echo ""
  90.                 echo "Could not remove installation directory."
  91.                 echo ""
  92.         end_it
  93.           fi
  94.         else
  95.       end_it_rm
  96.         fi
  97. }
  98.  
  99. # if prompt is required, do so
  100. prompt_choice() {
  101.   echo ""
  102.   echo "Which package from BOOSTWORKS would you like to install?\n"
  103.   echo ""
  104.   echo "1) BoostSQL Client"
  105.   echo "2) BoostSQL Server" 
  106.   echo "3) Exit Installation" 
  107.   echo ""
  108.   echo "Enter your selection:  \c"
  109.   read answer
  110.  
  111.   case "$answer" in
  112.      1) WHICHPROD="archive.tar.Z"
  113.         WHICHPRODNAME="BoostSQL Client"
  114.         WHICHSCRIPT="install"
  115.         SOFTPATH=$COMPANY_DIR/boostsql/sunos5
  116.         WHICHDIR=""
  117.         ;;
  118.      2)    WHICHPROD="" 
  119.     WHICHPRODNAME="BoostSQL Server" 
  120.         WHICHSCRIPT="install"
  121.         SOFTPATH=$COMPANY_DIR/boostsql/sunos5
  122.     WHICHDIR=""
  123.     ;;
  124.      3) end_it  
  125.     ;;
  126.      *) echo "Please choose one."
  127.     prompt_choice
  128.     ;;
  129.   esac
  130. }
  131. # if choice driven by .demosh script:
  132. auto_choice () {
  133.   case "$1" in
  134.      1) WHICHPROD=""
  135.         WHICHPRODNAME="Classic Blend"
  136.         install_script="cbInstall.bin"
  137.         ;;
  138.      2) WHICHPROD="NotifyServer"
  139.         WHICHPRODNAME="IPnetWATCHER Notification Server"
  140.         installdir=NotificationServer11woJRE
  141.         ;;
  142.   esac   
  143.  
  144. }
  145. # if system installation is required
  146. prompt_path () {
  147. installdir="$HOME"
  148. echo ""
  149. echo "Please enter an install path to begin installing $WHICHPRODNAME:"
  150.  
  151. echo "\n<$installdir>\c";read path
  152. if [ -n "$path" ]; then
  153. installdir="$path"
  154. fi
  155. verify_path $installdir
  156. }
  157.  
  158. verify_path () {
  159. installdir=$1
  160. if [ ! -d $installdir ]; then
  161.         echo "$installdir does not exist, create it?"
  162.     echo "\n<[y/n] y>\c";read x
  163.     if [ "$x" = "" ];then x="y"
  164.     fi
  165.     if [ $x = "y" -o $x = "yes" -o $x = "Yes" -o $x = "Y" ];then 
  166.           mkdir -p $installdir
  167.           if [ ! -d $installdir ]; then
  168.         echo ""
  169.                 echo "Could not create destination directory."
  170.                 prompt_path 
  171.           fi
  172.     else
  173.       end_it "A destination directory needs to be specified."
  174.     fi
  175. fi
  176. if [ ! -w $installdir ];then
  177.     echo "You can not write to $installdir" 
  178.     prompt_path
  179. fi
  180.  
  181. FREE_SPACE=0
  182. df=/tmp/FREE.$$
  183. /usr/bin/df -k $installdir | sed /kbytes/d | sed -e '3,$d' | sed -e '1,$s/  */ /g' > $df
  184. case `/usr/bin/wc -l $df | sed -e 's/^ *//' | cut -f1 -d" " ` in
  185.         1) FREE_SPACE=`cat $df | cut -f4 -d" "` ;;
  186.         2) FREE_SPACE=`cat $df | sed 1d | sed 's/^ *//' | cut -f3 -d" "` ;;
  187. esac
  188. if [ -n $FREE_SPACE ]
  189. then
  190.         if [ $FREE_SPACE -lt $PRODUCT_SIZE ]
  191.         then
  192.            echo
  193.            echo "The product installation requires $PRODUCT_SIZE kbytes of"
  194.            echo "free disk space. There is only $FREE_SPACE kbytes of free"
  195.            echo "disk space in the selected filesystem.  Please free up some"
  196.            echo "disk space, or choose another directory."
  197.                 prompt_path
  198.         fi
  199. fi
  200. /bin/rm $df 2>/dev/null
  201.  
  202. return 0 
  203. }
  204.  
  205. #*****************
  206. #  end subs
  207. #*****************
  208.  
  209. #Variables
  210. theARGS=$1
  211. PRODUCT_SIZE='250000'
  212. WHICHPROD=
  213. WHICHPRODNAME=
  214. #installdir=/tmp/demo.$$
  215. installdir=$COMPANY_DIR/_install
  216. export PRODUCT_SIZE WHICHPROD WHICHPRODNAME installdir theARGS
  217.  
  218.   echo ""
  219.   echo 
  220.  
  221. ##  Call out Subs here ###
  222.  
  223. #check_root
  224. #check_root_maybe
  225. auto_choice $theARGS
  226. #prompt_choice
  227. #prompt_path
  228.  
  229.  
  230. # below is custom for each demo
  231.  
  232. echo ""
  233. echo "$WHICHPRODNAME software installation starting..."
  234. echo ""
  235. echo "This may take a few minutes..."
  236. echo ""
  237. #mkdir -p $installdir
  238. #verify_path $installdir
  239. #chmod -R 777 $installdir
  240. cd $installdir
  241. ./$install_script
  242. echo ""
  243. #echo "Launching $WHICHPRODNAME installation ..."
  244. echo ""
  245. #zcat $COMPANY_DIR/_install/java/cloudscape.cpio.Z | cpio -icdV 
  246.  
  247. #$CD_MOUNT/products/bin/java/$CDWARE_ENV/bin/jre setup
  248.  
  249. #         if [ "$WHICHPROD" = "*.Z" ]
  250. #         then
  251. #             cp $SOFTPATH/client/* $installdir 
  252. #             cd $installdir
  253. #             chmod 777 *
  254. #             ./install
  255. #         else
  256. #             cp -r $SOFTPATH/server/* $installdir 
  257. #             cd $installdir
  258. #             chmod 777 *       
  259. #             ./install
  260. #         fi
  261. #CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/jar.jar
  262. #export CLASSPATH
  263.  
  264. #cd /tmp
  265. #rm -r $installdir
  266.  
  267. end_it
  268.